<?php
/* 
 * This class finds the right Controller and Action according to the passed URL
 * and Routes.
 */

/**
 * Description of Router
 *
 * @author PLeblanc
 */
final class Smvc_Router {

    public static function route($url) {

        require_once(APP_PATH . DS . 'config' . DS . 'routes.php');

        foreach ( $routes as $pattern => $controllerAndAction ) {
            if ( preg_match('/^'. $pattern . '/', $url ) ) {
                $requestString = preg_replace('/^'.$pattern . '/', '', $url,1);

                return array($controllerAndAction, $requestString);
            }
	}
        
        //we should always find a route. If not, there is problem.
        throw new Exception('No routes were found');

    }


}